﻿using System.Windows.Forms;
using sgs_Entity;
using sgs_Common;
using Microsoft.VisualBasic.PowerPacks;
using System.Drawing;

namespace Debugger.MyControls
{
    /// <summary>
    /// 玩家头像控件
    /// </summary>
    public partial class ucPlayer : UserControl
    {
        #region 常量
        /// <summary>
        /// 血量位置横坐标（右）
        /// </summary>
        private const int BloodLocationX_R = 170;
        /// <summary>
        /// 血量位置纵坐标（上）
        /// </summary>
        private const int BloodLocationY_U = 110;
        /// <summary>
        /// 血量间隔
        /// </summary>
        private const int BloodInterval = 7;
        #endregion

        #region 属性
        /// <summary>
        /// 国别
        /// </summary>
        public Kingdom Kingdom { get; set; }
        /// <summary>
        /// 武将名
        /// </summary>
        public WarriorName WarriorName { get; set; }
        /// <summary>
        /// 血量上限
        /// </summary>
        public int BloodLimit { get; set; }
        /// <summary>
        /// 血量
        /// </summary>
        public int Blood { get; set; }
        /// <summary>
        /// 手牌数
        /// </summary>
        public int CardNum { get; set; }
        #endregion


        /// <summary>
        /// 控件生成函数
        /// </summary>
        public ucPlayer(Player Player)
        {
            InitializeComponent();

            // 初始化玩家控件
            InitialPlayer(Player);
        }

        /// <summary>
        /// 初始化玩家控件
        /// </summary>
        public void InitialPlayer(Player Player)
        {
            // 武将名、国别、手牌数、血量
            lblKingdom.Text = EnumConvert.GetKingdomString(Player.Warrior.Kingdom);
            lblKingdom.ForeColor = EnumConvert.GetKingdomColor(Player.Warrior.Kingdom);
            lblWarriorName.Text = Player.Warrior.Name.ToString();
            lblCardNum.Text = "4";
            SetBlood(Player.Warrior.Blood);
        }
        /// <summary>
        /// 设置血量
        /// </summary>
        /// <param name="Blood"></param>
        private void SetBlood(int Blood)
        {
            for (int i = 0; i < Blood; i++)
            {
                OvalShape osBlood = new OvalShape();
                osBlood.Size = new Size(18, 18);
                osBlood.FillColor= Color.Green;
                osBlood.FillStyle = FillStyle.Solid;
                osBlood.BorderColor= Color.Transparent;
                shapeContainer1.Shapes.Add(osBlood);

                if (i < 5)
                {
                    osBlood.Location = new Point(BloodLocationX_R - i * (BloodInterval + osBlood.Size.Width), BloodLocationY_U);
                }
                else
                {
                    osBlood.Location = new Point(BloodLocationX_R - (i - 5) * (BloodInterval + osBlood.Size.Width), BloodLocationY_U + BloodInterval + osBlood.Size.Width);
                }
            }
        }
    }
}
